/**
 * Copyright 2010 Pavel Daniel Alexandru PFA
 * 
 * Licensed under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation. You may obtain a copy of the
 * License at: http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.kobol.webclient.client.widgets;

import com.kobol.webclient.client.Webclient;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;

/**
 * @author Pavel Alexandru
 * 
 */
public class StatusBar extends HLayout {

    private static final String STATUSBAR_HEIGHT = "23px";

    public StatusBar() {
	super();

	// initialise the StatusBar layout container
	this.setStyleName("crm-StatusBar");
	this.setHeight(STATUSBAR_HEIGHT);

	// initialise the Selected label
	Label selectedLabel = new Label();
	selectedLabel.setStyleName("crm-StatusBar-Label");
	selectedLabel.setContents(Webclient.getConstants().SelectedLabel());
	selectedLabel.setAlign(Alignment.LEFT);
	selectedLabel.setOverflow(Overflow.HIDDEN);

	// initialise the Result Set First button
	ImgButton resultSetFirstButton = new ImgButton();
	resultSetFirstButton.setShowRollOver(false);
	resultSetFirstButton.setShowDisabled(false);
	resultSetFirstButton.setShowDown(false);
	resultSetFirstButton.setSize(12);
	resultSetFirstButton.setLayoutAlign(VerticalAlignment.CENTER);
	resultSetFirstButton.setSrc("statusbar/resultsetfirst.png");

	// initialise the Result Set Previous button
	ImgButton resultSetPreviousButton = new ImgButton();
	resultSetPreviousButton.setShowRollOver(false);
	resultSetPreviousButton.setShowDisabled(false);
	resultSetPreviousButton.setShowDown(false);
	resultSetPreviousButton.setSize(12);
	resultSetPreviousButton.setLayoutAlign(VerticalAlignment.CENTER);
	resultSetPreviousButton.setSrc("statusbar/resultsetprevious.png");

	// initialise the Page Number label
	Label pageNumberLabel = new Label();
	pageNumberLabel.setStyleName("crm-StatusBar-Label");
	pageNumberLabel.setContents(Webclient.getConstants().PageNumberLabel());
	pageNumberLabel.setWidth(50);
	pageNumberLabel.setAlign(Alignment.RIGHT);
	pageNumberLabel.setOverflow(Overflow.HIDDEN);

	// initialise the Result Set Next button
	ImgButton resultSetNextButton = new ImgButton();
	resultSetNextButton.setShowRollOver(false);
	resultSetNextButton.setShowDisabled(false);
	resultSetNextButton.setShowDown(false);
	resultSetNextButton.setSize(12);
	resultSetNextButton.setLayoutAlign(VerticalAlignment.CENTER);
	resultSetNextButton.setSrc("statusbar/resultsetnext.png");

	// add the widgets to the StatusBar layout container
	this.addMember(selectedLabel);
	// force right alignment
	Label alignRight = new Label("&nbsp;");
	alignRight.setAlign(Alignment.RIGHT);
	alignRight.setOverflow(Overflow.HIDDEN);
	this.addMember(alignRight);
	this.addMember(resultSetFirstButton);
	this.addMember(resultSetPreviousButton);
	this.addMember(pageNumberLabel);
	this.addMember(resultSetNextButton);
	// add some padding
	LayoutSpacer paddingRight = new LayoutSpacer();
	paddingRight.setWidth(8);
	this.addMember(paddingRight);
    }
}